package org.glutenberg;

import com.sun.lwuit.Command;
import com.sun.lwuit.Font;
import com.sun.lwuit.Form;
import com.sun.lwuit.Label;
import com.sun.lwuit.TextArea;
import com.sun.lwuit.TextField;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import com.sun.lwuit.layouts.BoxLayout;
import com.sun.lwuit.plaf.Style;

public class NotFound extends Form implements ActionListener {
	
	private Command exit;
	private Command find;
	private Command aboutCommand;
	private Handbook hb;
	
	private static String NOT_FOUND = "Nessun risultato trovato";

	public NotFound(Handbook hb){
		this.hb = hb;
		this.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
		this.setTitleComponent(Results.getTitle(Results.TITLE));
		this.exit = new Command("Esci");
		this.find = new Command("Cerca");
		this.aboutCommand = About.getAboutCommand();
		this.addCommandListener(this);
		this.addCommand(this.find);
		this.addCommand(this.exit);
		this.addCommand(this.aboutCommand);
		this.addComponent(this.getNotFoundLabel(NOT_FOUND));
	}
	
	private Label getNotFoundLabel(String notFound){
		Label titleL = new Label(notFound);
		titleL.setFocusable(false);
		Style s = new Style();
		s.setFont(Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_LARGE));
		titleL.setSelectedStyle(s);
		titleL.setUnSelectedStyle(s);
		titleL.setAlignment(CENTER);
		return titleL;
	}
	
	public void actionPerformed(ActionEvent ev) {
		Command c = ev.getCommand();
		if(c==this.exit){
			this.hb.quit();
		} else if(c==this.find){
			this.hb.find();
		} else if(c==this.aboutCommand){
			this.hb.about(this);
		}	
	}
}
